package com.example.demo.day.config.learn.design.builder.x1;

public class Computer {
    private String mMainBoard;
    private String mDisplayer;
    private String mKeyBoard;
    private String mMouse;

    public Computer(String mMainBoard, String mDisplayer, String mKeyBoard, String mMouse) {
        this.mDisplayer = mDisplayer;
        this.mMainBoard = mMainBoard;
        this.mKeyBoard = mKeyBoard;
        this.mMouse = mMouse;
    }

    //提供一个静态方法，以此管理或简化Builder内部实例的获取
    public static Builder newBuilder() {
        return new Builder();
    }

    //内部静态的建造者类
    public static class Builder {
        private String mMainBoard;
        private String mDisplayer;
        private String mKeyBoard;
        private String mMouse;

        public Builder() {
            mMainBoard = "默认主板";
            mDisplayer = "默认显示器";
            mKeyBoard = "默认键盘";
            mMouse = "默认鼠标";
        }

        public Builder setMainBoard(String mainBoard) {
            mMainBoard = mainBoard;
            return this;
        }

        public Builder setDisplayBoard(String displayBoard) {
            mDisplayer = displayBoard;
            return this;
        }

        public Builder setKeyBoard(String keyBoard) {
            mKeyBoard = keyBoard;
            return this;
        }

        public Builder setMouse(String mouse) {
            mMouse = mouse;
            return this;
        }

        public Computer build() {
            return new Computer(mMainBoard, mDisplayer, mKeyBoard, mMouse);
        }
    }

    public String getmMainBoard() {
        return mMainBoard;
    }

    public void setmMainBoard(String mMainBoard) {
        this.mMainBoard = mMainBoard;
    }

    public String getmDisplayer() {
        return mDisplayer;
    }

    public void setmDisplayer(String mDisplayer) {
        this.mDisplayer = mDisplayer;
    }

    public String getmKeyBoard() {
        return mKeyBoard;
    }

    @Override
    public String toString() {
        return "Computer{" +
                "mMainBoard='" + mMainBoard + '\'' +
                ", mDisplayer='" + mDisplayer + '\'' +
                ", mKeyBoard='" + mKeyBoard + '\'' +
                ", mMouse='" + mMouse + '\'' +
                '}';
    }

    public void setmKeyBoard(String mKeyBoard) {
        this.mKeyBoard = mKeyBoard;
    }

    public String getmMouse() {
        return mMouse;
    }

    public void setmMouse(String mMouse) {
        this.mMouse = mMouse;
    }
}
